package taskman.ui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JScrollPane;

import taskman.Task;
import taskman.xml.XmlHelper;

public class Interface3ManagementWindow extends JFrame {


	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Interface3ManagementWindow frame = new Interface3ManagementWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Interface3ManagementWindow() {
		setTitle("Interface3 Management");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JLabel lblInterface3Management = new JLabel("Interface3 Management");
		contentPane.add(lblInterface3Management, BorderLayout.NORTH);
		
		JScrollPane scrollPane = new JScrollPane();
		contentPane.add(scrollPane, BorderLayout.CENTER);
		
		//Creating the table
		table = new JTable();
		DefaultTableModel model = new DefaultTableModel();
		
		//Adding the header of each column
		model.addColumn("Id");
		model.addColumn("Title");
		//model.addColumn("Description");
		//model.addColumn("Duration");
		//model.addColumn("Delivarable");
		//model.addColumn("Deadline");
		model.addColumn("Person Id");
		
		//Getting all the tasks from the XmlHelper, inorder to put them in the table
		for(Task t : XmlHelper.loadAllTasks())
		{
			model.addRow(new Object[]{t.getId(), t.getTitle(), t.getPersonId()});
		}
		
		
		table.setModel(model);
		table.getColumnModel().getColumn(0).setResizable(true);
		table.getColumnModel().getColumn(1).setResizable(true);
		table.getColumnModel().getColumn(2).setResizable(true);
		//table.getColumnModel().getColumn(3).setResizable(true);
		//table.getColumnModel().getColumn(4).setResizable(true);
		//table.getColumnModel().getColumn(5).setResizable(true);
		//table.getColumnModel().getColumn(6).setResizable(true);
	
		
		
		scrollPane.setViewportView(table);
		
		
	}
	
	

}